<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>首页提示</title>
    <th:block th:include="include :: header('首页提示')"/>
    <th:block th:include="include :: select2-css"/>
    <link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link href="../static/css/bootstrap-table.min.css" th:href="@{/ajax/libs/bootstrap-table/bootstrap-table.min.css}"
          rel="stylesheet"/>
    <link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <link href="../static/css/animate.min.css" th:href="@{/css/animate.min.css}" rel="stylesheet"/>
    <link href="../static/css/style.min.css" th:href="@{/css/style.min.css}" rel="stylesheet"/>
</head>
<style>
    body {
        background: url(/img/rightback.jpg) no-repeat;
        background-position-x: right;
    }

</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">

    <div class="row">
        <!--<div class="col-sm-3" style="float: left;width: 180px" hidden>
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    &lt;!&ndash;                        <span class="label label-success pull-right">仓库</span>&ndash;&gt;
                    <h5>当前仓库</h5>
                </div>
                <div class="ibox-content">
                    &lt;!&ndash;                    <div class="radio">&ndash;&gt;
                    <div class="form-check">
                        <input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault1"
                               onclick="queryInfo(1)">
                        <label class="form-check-label" for="flexRadioDefault1">
                            成品库
                        </label>
                    </div>
                    <div class="form-check">
                        <input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault2"
                               checked onclick="queryInfo(1)">
                        <label class="form-check-label" for="flexRadioDefault2">
                            半成品库
                        </label>
                    </div>
                </div>
            </div>
        </div>-->

        <div class="col-sm-4" style="float: left;width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-info pull-right">全天</span>
                    <h5>托盘库空货位</h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins">
                        <input type="text"
                               style="text-align: center;width: 100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                               id="all_stock" disabled>
                    </h1>

                </div>
            </div>
        </div>
        <div class="col-sm-4" style="float: left;width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-info pull-right">全天</span>
                    <h5>托盘库总货位</h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins">
                        <input type="text"
                               style="text-align: center;width: 100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                               id="per_stock" disabled>
                    </h1>
                </div>
            </div>
        </div>
        <div class="col-sm-4" style="float: left;width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-danger pull-right">当天</span>
                    <h5>托盘库入库托盘数量</h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins">
                        <input type="text"
                               style="text-align: center;width: 100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                               id="in_count" disabled>
                    </h1>
                </div>
            </div>
        </div>
        <div class="col-sm-4" style="float: left;width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-warning pull-right">当天</span>
                    <h5>托盘库出库托盘数量</h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins">
                        <input type="text"
                               style="text-align: center;width: 100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                               id="out_count" disabled>
                    </h1>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-4" style="float: left;width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-info pull-right">全天</span>
                    <h5>料箱库空货位</h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins">
                        <input type="text"
                               style="text-align: center;width: 100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                               id="all_stock2" disabled>
                    </h1>

                </div>
            </div>
        </div>

        <div class="col-sm-4" style="float: left;width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-info pull-right">全天</span>
                    <h5>料箱库总货位</h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins">
                        <input type="text"
                               style="text-align: center;width: 100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                               id="per_stock2" disabled>
                    </h1>
                </div>
            </div>
        </div>



        <!--  <div class="col-sm-4" style="float: left;width: 17%">
              <div class="ibox float-e-margins">
                  <div class="ibox-title">
                      <span class="label label-info pull-right">当前</span>
                      <h5>入库分配</h5>
                  </div>
                  <div class="ibox-content">
                      <h1 class="no-margins">
                          <input type="text"
                                 style="text-align: center;width:100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                                 id="all_stock_in" disabled>
                      </h1>
                  </div>
              </div>
          </div>

          <div class="col-sm-4" style="float: left;width:17%">
              <div class="ibox float-e-margins">
                  <div class="ibox-title">
                      <span class="label label-info pull-right">当前</span>
                      <h5>出库分配</h5>
                  </div>
                  <div class="ibox-content">
                      <h1 class="no-margins">
                          <input type="text"
                                 style="text-align: center;width: 100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                                 id="all_stock_out" disabled>
                      </h1>
                  </div>
              </div>
          </div>-->


        <div class="col-sm-4" style="float: left;width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-warning pull-right">当天</span>
                    <h5>料箱库出库托盘数量</h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins">
                        <input type="text"
                               style="text-align: center;width: 100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                               id="out_count2" disabled>
                    </h1>
                </div>
            </div>
        </div>

        <div class="col-sm-4" style="float: left;width: 20%">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <span class="label label-danger pull-right">当天</span>
                    <h5>料箱库入库托盘数量</h5>
                </div>
                <div class="ibox-content">
                    <h1 class="no-margins">
                        <input type="text"
                               style="text-align: center;width: 100%;font-weight:bold;background-color: white;border: rgba(28,148,196,0)"
                               id="in_count2" disabled>
                    </h1>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>当天完成任务数明细</h5>
                <!--                    <h5 style="float: right">设备概览</h5>-->
            </div>
            <div class="ibox-content">
                <div class="row">
                    <div class="col-sm-9">
                        <div style="width: 100%;height: 230px" id="taskCharts"></div>
                    </div>
                    <!-- <div class="col-sm-3">
                         <ul class="stat-list">

                             <li>
                                 <h2 class="no-margins">
                                     <input type="text"
                                            style="width: 150px;background-color: white;border: rgba(28,148,196,0)"
                                            id="online" disabled>
                                 </h2>
                                 <small>设备联机数</small>
                                 <div class="stat-percent">
                                     <input type="text" id="online_per"
                                            style="background-color: white;border: rgba(28,148,196,0);text-align: right"
                                            disabled>
                                     <i class="fa fa-bolt text-navy"></i>
                                 </div>
                                 <div class="progress progress-mini">
                                     <div class="progress-bar" id="online_load"></div>
                                 </div>
                             </li>
                             <li>
                                 <h2 class="no-margins ">
                                     <input type="text"
                                            style="width: 150px;background-color: white;border: rgba(28,148,196,0)"
                                            id="dev_work" disabled>
                                 </h2>
                                 <small>设备工作数</small>
                                 <div class="stat-percent">
                                     <input type="text" id="work_per"
                                            style="background-color: white;border: rgba(28,148,196,0);text-align: right"
                                            disabled>
                                     <i class="fa fa-bolt text-navy"></i>
                                 </div>
                                 <div class="progress progress-mini">
                                     <div class="progress-bar" id="work_load"></div>
                                 </div>
                             </li>
                             <li>
                                 <h2 class="no-margins ">
                                     <input type="text"
                                            style="width: 150px;background-color: white;border: rgba(28,148,196,0)"
                                            id="dev_warn" disabled>
                                 </h2>
                                 <small>设备故障数</small>
                                 <div class="stat-percent">
                                     <input type="text" id="warn_per"
                                            style="background-color: white;border: rgba(28,148,196,0);text-align: right"
                                            disabled>
                                     <i class="fa fa-bolt text-navy"></i>
                                 </div>
                                 <div class="progress progress-mini">
                                     <div class="progress-bar" id="warn_load"></div>
                                 </div>
                             </li>
                         </ul>
                     </div>-->
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>正执行任务概览</h5>
            </div>
            <div class="ibox-content">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>
</div>
</div>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/ajax/libs/flot/jquery.flot.js}"></script>
<th:block th:include="include :: echarts227-js"/>
<th:block th:include="include :: jquery-cxselect-js"/>
<script th:src="@{/ajax/libs/bootstrap-table/bootstrap-table.min.js}"></script>
<script th:src="@{/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}"></script>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var dsDatas = [[${@dict.getType('space_ds')}]];
    var statusDatas = [[${@dict.getType('space_status')}]];
    var prefix = ctx + "stock/stock";

    $(function () {
        queryInfo(1);
    })

    function queryInfo(warehouseId) {
        // var warehouseId = $("input[type='radio']:checked").val();
        // querySpaceList(warehouseId);
        // queryStockList(warehouseId);
        queryJobList(warehouseId);
        getTaskCharts(warehouseId);
        getDevInfo(warehouseId);
        getJobInfo(warehouseId);

    }

    // function queryStockList(warehouseId) {
    //     $.post("/kpi/stockList", {
    //         warehouseId: warehouseId
    //     }, function (result) {
    //         $("#all_stock").val(result.allStock);
    //         $("#per_stock").val(result.perStock);
    //     });
    // }
    //
    // function querySpaceList(warehouseId) {
    //     $.post("/kpi/spaceList", {
    //         warehouseId: warehouseId
    //     }, function (result) {
    //         $("#use_space").val(result.useSpace);
    //         $("#all_space").val(result.allSpace);
    //     });
    // }

    function queryJobList(warehouseId) {
        $.post("/main/jobList", {
            warehouseId: warehouseId
        }, function (result) {
            $("#in_count").val(result.inJob);
            $("#in_count2").val(result.inJob2);
            $("#out_count").val(result.outJob);
            $("#out_count2").val(result.outJob2);
            $("#all_stock_in").val(result.pastInJob);
            $("#all_stock_out").val(result.pastOutJob);
            $("#all_stock").val(result.KtpNUm);//托盘库空货位
            $("#all_stock2").val(result.KtpNUm2);//料箱库空货位
            $("#per_stock").val(result.countSum);//托盘库总货位
            $("#per_stock2").val(result.countSum2);//料箱库总货位

        });
    }

    function getTaskCharts(warehouseId) {
        var myChart = echarts.init(document.getElementById('taskCharts'))
        myChart.showLoading();
        $.post("/main/findMinutesRecord", {
            warehouseId: warehouseId
        }, function (result) {
            myChart.hideLoading();
            myChart.setOption({
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross'
                    }
                },
                toolbox: {
                    show: true,
                    feature: {
                        saveAsImage: {}
                    }
                },
                grid: {
                    width: "93%",
                    x: "3%",
                    height: "85%",
                    y: "3%",
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    // prettier-ignore
                    data: result.dates
                },
                yAxis: {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value}'
                    },
                    axisPointer: {
                        snap: true
                    }
                },
                visualMap: {
                    show: false,
                    dimension: 0,
                    pieces: [
                        {
                            lte: 6,
                            color: 'skyblue'
                        },
                        {
                            gt: 6,
                            lte: 8,
                            color: 'skyblue'
                        },
                        {
                            gt: 8,
                            lte: 14,
                            color: 'skyblue'
                        },
                        {
                            gt: 14,
                            lte: 17,
                            color: 'skyblue'
                        },
                        {
                            gt: 17,
                            color: 'skyblue'
                        }
                    ]
                },
                series: [
                    {
                        name: '数量',
                        type: 'line',
                        smooth: true,
                        data: result.data,
                        markArea: {
                            itemStyle: {
                                color: 'rgba(255, 173, 177, 0.4)'
                            },
                        }
                    }
                ]
            })
        });
    }

    function getDevInfo(warehouseId) {
        $.post("/main/findDevInfo", {
            warehouseId: warehouseId
        }, function (result) {
            $("#online").val(result.online);
            $("#online_per").val(result.onlinePer);
            $("#dev_work").val(result.work);
            $("#work_per").val(result.workPer);
            $("#dev_warn").val(result.warn);
            $("#warn_per").val(result.warnPer);
            $("#warn_load").css("width", result.warnPer);
            $("#online_load").css("width", result.onlinePer);
            $("#work_load").css("width", result.workPer);
        });
    }

    function getJobInfo(warehouseId) {
        $('#bootstrap-table').bootstrapTable('destroy');
        // var inOrOutDatas = [[${@dict.getType('mydo_job_in_or_out')}]];
        var prefix = "/main";

        var options = {
            url: prefix + "/listJobIng?warehouseId=" + warehouseId,
            modalName: "作业概览",
            pageSize: 5,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            search: false,
            // pagination:false,
            columns: [
                {
                    field: 'taskNo',
                    title: '任务号'
                },
                {
                    field: 'trayCode',
                    title: '托盘条码'
                },
                /*{
                    field: 'inOrOut',
                    title: '类型',
                    formatter: function (value, row, index) {
                        if (value == "1") {
                            return "物资成品出库";
                        }
                        if (value == "2") {
                            return "物资半成品出库";
                        }
                        if (value == "3") {
                            return "成品空托入库";
                        }
                        if (value == "4") {
                            return "半成品空托入库";
                        }
                        if (value == "10") {
                            return "成品物资出库";
                        }
                        if (value == "11") {
                            return "半成品物资出库";
                        }
                        if (value == "12") {
                            return "成品空托出库";
                        }
                        if (value == "13") {
                            return "半成品空托出库";
                        }
                        // if (value == "14") {
                        //     return "指定货位出库";
                        // }
                        if (value == "14") {
                            return "盘点出库";
                        }
                        if (value == "16") {
                            return "指定货位出库";
                        }
                        if (value == "5") {
                            return "盘点入库";
                        }
                    }
                },*/
                {
                    field: 'productId',
                    title: '物资编码'
                },
                {
                    field: 'productName',
                    title: '物料名称'
                },
                /* {
                     field: 'roadwayId',
                     title: '巷道号'
                 },*/

                {
                    field: 'number',
                    title: '数量'
                }

            ]
        };
        $.table.init(options);
        $("#bootstrap-table").bootstrapTable('hideLoading');
    }


</script>
</body>
</html>
